Repository navigation
[8.x] Fix images, variants and metafields syncing in reverse order - #236
Merged
Merged
Conversation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
[7.x] Fix images, variants and metafields syncing in reverse order
# Conflicts: # CHANGELOG.md # src/Plugin.php
# Conflicts: # src/records/ShopifyData.php
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review identified no blocking issues in the ordering logic, schema updates, or regression coverage; tests were not executed.
No open issues 🎉
What changed in this PR
Restores Shopify’s original image, variant, and metafield order during bulk syncing, addressing #161.
Changes:
- Stores bulk-file positions and retrieves rows by position, then ID.
- Adds the position column for existing and new installations.
- Adds a regression test covering image order across multiple batches.
| File | Description |
|---|---|
| tests/unit/jobs/ProcessBulkOperationDataTest.php | Tests image ordering across batches. |
| src/services/Api.php | Sorts by position, then ID. |
| src/records/ShopifyData.php | Documents the position property. |
| src/Plugin.php | Bumps the schema version. |
| src/migrations/m261016_090000_add_position_to_data_table.php | Adds position to existing installations. |
| src/migrations/Install.php | Includes position in new installations. |
| src/jobs/ProcessBulkOperationData.php | Saves each row’s bulk-file position. |
| CHANGELOG.md | Records the ordering fix and new property. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since 8.2.0 the bulk operation file is read from the last line to the first, so children get saved before their parent product. Child rows are now inserted in reverse Shopify order, and
Api::getShopifyDataByType()was sorting byid, soProduct.images(and variants and metafields) came back reversed.Each row now stores its line index from the bulk file in a new
positioncolumn, andgetShopifyDataByType()sorts byposition, thenid. Rows without a position (anything synced before this) fall back toid, so nothing changes for them until the next sync. A re-sync fixes order for sites already affected on 8.2.0.Added a job test that runs a product with five images through several small batches and checks they come back in file order. I also re-synced a store on the
nextdatabase and checked the image order against Shopify's API and in the control panel.Related issues
#161